import {reqBuyList,reqWaterFallList} from '@/api/buy'

const state = {
  navList : [],
  waterFallList:[]
};
const actions = {
  //获取值得买轮播图数据
 async getBuyList({state,dispatch,commit}){
    let result =await reqBuyList()
    //console.log(result)
    let navList = result.data.navList
    console.log(navList)
    commit('GETBUYLIST',navList)
  },
  //获取瀑布流数据
 async getWaterFall({state,dispatch,commit}){
     let result = await reqWaterFallList()
     console.log(result)
     let waterFallList = result.data.result
     commit('GETWATERFALL',waterFallList)
  }
};
const mutations = {
  GETBUYLIST(state,navList){
//修改state数据
state.navList = navList
  },
  GETWATERFALL(state,waterFallList){
    waterFallList.forEach(item =>state.waterFallList.push(item));
  }
};
const getters = {};

export default {
  namespaced: "buy",
  state,
  actions,
  mutations,
  getters,
};
